package com.wocao.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import com.wocao.system.entity.SysRoleDo;
import com.wocao.system.entity.SysUserRoleDo;
import com.wocao.system.mapper.SysRoleMapper;
import com.wocao.system.service.SysRoleService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;
import java.util.List;

/**
 * 角色接口实现类
 *
 * @author sunhao
 * @date 2021/8/14
 * @see [相关类/方法]（可选）
 * @since [产品/模块版本] （可选）
 */
@Service
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRoleDo> implements SysRoleService {

    @Override
    public List<SysRoleDo> listRolesByUserRoleList(List<SysUserRoleDo> userRoleList) {
        if (CollectionUtils.isEmpty(userRoleList)) {
            return null;
        }
        List<SysRoleDo> result = Lists.newArrayList();
        for (SysUserRoleDo userRoleDo : userRoleList) {
            result.add(this.getById(userRoleDo.getRoleId()));
        }
        return result;
    }
}
